<?php
/**
 * Created by PhpStorm.
 * User: xi
 * Date: 2020-04-25
 * Time: 17:08
 */

namespace app\api\service;


class CommonService
{

    public function verify($idcard, $name)
    {


        $host = "http://idcardcert.market.alicloudapi.com/idCardCert";
        $path = "";
        $method = "GET";
        $appcode = "7bb35d5f71874dd4a9367cb3b2ad7fa6";
        $headers = array();
        array_push($headers, "Authorization:APPCODE " . $appcode);
        $querys = "idCard=" . $idcard . "&name=" . $name;
        $bodys = "";
        $url = $host . $path . "?" . $querys;


        $curl = curl_init();
        curl_setopt($curl, CURLOPT_CUSTOMREQUEST, $method);
        curl_setopt($curl, CURLOPT_URL, $url);
        curl_setopt($curl, CURLOPT_HTTPHEADER, $headers);
        curl_setopt($curl, CURLOPT_FAILONERROR, false);
        curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
        curl_setopt($curl, CURLOPT_HEADER, false);
//        curl_setopt($curl, CURLOPT_HEADER, true);  // 如不输出json, 请打开这行代码，打印调试头部状态码。
        //状态码: 200 正常；400 URL无效；401 appCode错误； 403 次数用完； 500 API网管错误
        if (1 == strpos("$" . $host, "https://")) {
            curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);
            curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, false);
        }
        $out_put = curl_exec($curl);

        return $out_put;
    }


    public function bankVerify($idcard, $name, $mobile, $account)
    {

        $host = "https://bcard3and4.market.alicloudapi.com";
        $path = "/bankCheck4";
        $method = "GET";
        $appcode = "c6b5f33b99c141c28c56772221ae82ef";
        $headers = array();
        array_push($headers, "Authorization:APPCODE " . $appcode);
        $querys = "accountNo=" . $account . "&idCard=" . $idcard . "&mobile=" . $mobile . "&name=" . $name;
        $bodys = "";
        $url = $host . $path . "?" . $querys;

        $curl = curl_init();
        curl_setopt($curl, CURLOPT_CUSTOMREQUEST, $method);
        curl_setopt($curl, CURLOPT_URL, $url);
        curl_setopt($curl, CURLOPT_HTTPHEADER, $headers);
        curl_setopt($curl, CURLOPT_FAILONERROR, false);
        curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
        curl_setopt($curl, CURLOPT_HEADER, false);
        //curl_setopt($curl, CURLOPT_HEADER, true); 如不输出json, 请打开这行代码，打印调试头部状态码。
        //状态码: 200 正常；400 URL无效；401 appCode错误； 403 次数用完； 500 API网管错误
        if (1 == strpos("$" . $host, "https://")) {
            curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);
            curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, false);
        }
        $out_put = curl_exec($curl);
        return $out_put;
    }

}